/**
 * @description
 * @author cx
 * @date 2024.06.07 14:24
 */


package com.cx.service.yitu.config;

import lombok.extern.slf4j.Slf4j;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

import java.io.IOException;

@Slf4j
public class RetrofitInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();

        //获取当前接口值
        //String path = chain.request().url().encodedPath();
        //System.out.println("path的值为"+path);

        RequestBody body = request.body();
        System.out.println("body的值为===" + body);

        request = request.newBuilder()
                .addHeader("Accept", "application/json")
                // .addHeader("Content-Type", "application/json")
//                .addHeader("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IkFQSV9WQUxJREFUSU9OX1NJR05JTkcifQ.eyJzdWIiOiJhcGkiLCJhdWQiOiJ3ZWIiLCJleHAiOjE2OTgxMzY4NzQsIm5iZiI6MTY5NzUzMjA3NCwiaWF0IjoxNjk3NTMyMDc0fQ.nCweajNi-bldTOFXsFTLdY1T0PRxVRSJzPZIKUjSTHzx_fX9G6fW60zh13bzDpo3WLt2lMmIrtFyjM7UPwlBqQ")
                .addHeader("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IkFQSV9WQUxJREFUSU9OX1NJR05JTkcifQ.eyJzdWIiOiJhcGkiLCJhdWQiOiJ3ZWIiLCJleHAiOjE3MTk4MTE5OTMsIm5iZiI6MTcxOTIwNzE5MywiaWF0IjoxNzE5MjA3MTkzfQ.QbeBKL-lnkSb5XtEDetmaqUEI1aFqrusBb74KU5mWHpe2zHtXhN4g3F17zeJAbIPBFy_QxSa34wwW0HtDymNlQ")
                .build();

        log.info("接口信息-----" + request.toString());

        System.out.println(request.toString());

        Response response = chain.proceed(request);
        // 对响应进行处理...
        return response;

    }
}
